package com.changgou.controller;

import com.changgou.goods.pojo.Brand;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;
import java.util.Map;

/*****
 * @Author: www.itheima.com
 * @Description: com.changgou.goods.controller
 ****/
@RestController
@RequestMapping("/consumer")
public class BrandController {


    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RestTemplate restTemplate;

    public static final String REST_URL_PROD ="http://redisservice01";

    @RequestMapping("/getBrand")
    public Result<List<Brand>> getBrand(){
        return restTemplate.getForObject(REST_URL_PROD+"/brand/findAll",Result.class);
    }

    @RequestMapping("/getIndex/{keyword}")
    public List<?> getIndex(@PathVariable("keyword") String keyword){
        return restTemplate.getForObject(REST_URL_PROD+"/index/getIndexJd/"+keyword,List.class);
    }

    @RequestMapping("/testas")
    public String testas(String keyword){
        return "asda";
    }


}
